package cn.rkylin.oms.warehouseDocking.dao.qimen;

import cn.rkylin.core.IDataBaseFactory;
import cn.rkylin.oms.warehouseDocking.vo.qimen.GoodsSynchronize;
import cn.rkylin.oms.warehouseDocking.vo.qimen.ReturnStockInCreate;
import cn.rkylin.oms.warehouseDocking.vo.qimen.ReturnStockInSkuCreate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * 奇门退货入库单创建数据访问层具体实现
 *
 * @author fengwang
 * @created 2017年11月7日
 */

@Repository(value = "iReturnStockInCreateDAO")
public class ReturnStockInCreateDAOImpl implements IReturnStockInCreateDAO {

    @Autowired
    protected IDataBaseFactory dao;

    private static final String selectInfoReturnStockInIdByPrjIdAndStorId = "selectInfoReturnStockInIdByPrjIdAndStorId";

    private static final String selectInfoReturnStockInByPrjIdAndStorId = "selectInfoReturnStockInByPrjIdAndStorId";

    private static final String selectInfoReturnStockInSkuByStockId = "selectInfoReturnStockInSkuByStockId";

    @Override
    public List<ReturnStockInCreate> selectInfoReturnStockInIdByPrjIdAndStorId(Map<String, Object> reqMap) throws Exception {
        List<ReturnStockInCreate> rList = dao.findAllList(selectInfoReturnStockInIdByPrjIdAndStorId, reqMap);
        return rList;
    }

    @Override
    public ReturnStockInCreate selectInfoReturnStockInByPrjIdAndStorId(Map<String, Object> reqMap) throws Exception {
        ReturnStockInCreate rList = (ReturnStockInCreate) dao.findForObject(selectInfoReturnStockInByPrjIdAndStorId, reqMap);
        return rList;
    }

    @Override
    public List<ReturnStockInSkuCreate> selectInfoReturnStockInSkuByStockId(Map<String, Object> reqMap) throws Exception {
        List<ReturnStockInSkuCreate> rList = dao.findAllList(selectInfoReturnStockInSkuByStockId, reqMap);
        return rList;
    }

    /**
     * 获取系统规格 即时成本价
     *
     * @param skuId
     * @return
     * @throws Exception
     */
    @Override
    public GoodsSynchronize selectGoodsSkuCostBySkuId(String skuId) throws Exception {
        List<GoodsSynchronize> goodsSkuList = dao.findList("selectGoodsSkuCostBySkuId", skuId);
        if (goodsSkuList != null && goodsSkuList.size() > 0) {
            return goodsSkuList.get(0);
        }
        return null;
    }

}
